home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / prog_disc / volume_3 / issue04 / c / c_4_5 < prev    next >
Encoding:
Text File  |  1989-12-11  |  457 b   |  24 lines

  1. #include <stdio.h>
  2.  
  3. void copyfiles( FILE *source, FILE *sink )
  4.     {
  5.     int ch;
  6.     while ((ch = fgetc( source )) != EOF) fputc( ch, sink );
  7.     }
  8.  
  9. int main( int argc, char *argv[] )
  10.     {
  11.     FILE *source = fopen( "myfile", "r" );
  12.     if (source)
  13.         {
  14.         copyfiles( source, stdout );
  15.         fclose( source );
  16.         return 0;
  17.         }
  18.     else
  19.         {
  20.         fprintf( stderr, "Could not open myfile\n" );
  21.         return 1;
  22.         }
  23.     }
  24.